const { addBlogDao, updateBlogDao, delBlogDao, getBlogByIdDao, getBlogByPageDao } = require("../dao/blogDao")
const { addBlogTypeNumDao } = require("../dao/blogTypeDao")

module.exports.addBlogService = async function (blog) {
  let result = await addBlogDao(blog)
  await addBlogTypeNumDao(blog.categoryId)
  return result
}

module.exports.updateBlogService = async function (id, blog) {
  return await updateBlogDao(id, blog)
}

module.exports.delBlogService = async function (id, blog) {
  return await delBlogDao(id, blog)
}

module.exports.getBlogByIdService = async function (id) {
  return await getBlogByIdDao(id)
}

module.exports.getBlogByPageService = async function (query) {
  return await getBlogByPageDao(query)
}